<?php

namespace App\Models\Api;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Api\Base;

class ZodiacSign extends Base
{
    use HasFactory;

    protected $fillable = [
        'type', 'title', 'avatar', 'tags', 'content', 'in_sign', 'relation_id', 'tip', 'tags_color', 'tags_bg_color'
    ];

    protected $casts = [
        'tags' => 'array',
    ];

    public function weeklyHoroscopes()
    {
        return $this->hasMany(WeeklyHoroscope::class);
    }
    
    public function getZodiacSignNameAttribute()
    {
        $signs = [
            1 => '白羊座',
            2 => '金牛座',
            3 => '双子座',
            4 => '巨蟹座',
            5 => '狮子座',
            6 => '处女座',
            7 => '天秤座',
            8 => '天蝎座',
            9 => '射手座',
            10 => '摩羯座',
            11 => '水瓶座',
            12 => '双鱼座'
        ];

        return $signs[$this->in_sign] ?? '未知';
    }
    
    public function getRelationTypeNameAttribute()
    {
        $relations = [
            1 => '自己',
            2 => '恋人',
            3 => '朋友',
            4 => '同事',
            5 => '亲人',
            6 => '老板',
            7 => '前任',
            8 => '男生',
            9 => '女生'
        ];

        return $relations[$this->relation_id] ?? '未知';
    }
    
    public function getTypeNameAttribute()
    {
        $types = [
            'overall' => '总体分析',
            'relation' => '关系分析'
        ];
        return $types[$this->type] ?? '未知';
    }
}